package com.module.app.adapter.holder;

import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.databinding.ViewDataBinding;

import com.module.base.base.adapter.BaseViewHolder;
import com.module.base.bean.Decoration;
import com.module.base.R;

/**
 * @author bsnl_yanxuwen
 * @date 2020/10/27 10:13
 * Description :
 * 分割图,默认10dp
 */
public class DecorationVH extends BaseViewHolder<Decoration, ViewDataBinding> {

    ImageView image;

    public DecorationVH(ViewGroup parent) {
        super(parent, R.layout.item_decoration);
    }

    @Override
    public void initView() {
        super.initView();
        image = itemView.findViewById(R.id.image);
    }

    @Override
    protected void convert(Decoration bean, int position) {
        if (bean.getHeight() > 0) {
            ViewGroup.LayoutParams lp = image.getLayoutParams();
            lp.height = bean.getHeight();
            image.setLayoutParams(lp);
        }

        image.setBackgroundResource(bean.getResId());
    }
}
